package stack;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 */
public class MyStack {
    public int size;
    public int[] array;
    public  MyStack(){
        array =new int[10];
    }
    private void grow(){
        array = Arrays.copyOf(array,array.length*2);
    }
    public int size(){
        return size;
    }
    private boolean isFull(){
        return size==array.length;
    }
    public Boolean empty(){
        return size==0;
    }
    public void push(int data){
        if (isFull()){
            grow();
        }
        array[size]=data;
        size++;
    }
    public int pop(){
        if (empty()){
            return -1;
        }
        return array[--size];
    }
    public int peek(){
        if (empty()){
            return -1;
        }
        return array[size-1];
    }



}
